﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 接口
{
    class Invoice:IPayable
    {
        private int quantity;
        private decimal pricePerItem;

        public string PartDescription { get; set; }
        public string PartNumber { get; set; }

        public Invoice(string description, string number, int count, decimal price)
        {
            PartDescription = description;
            PartNumber = number;
            Quantity = count;
            PricePerItem = price;
        }//end constructor Invoice

        public override string ToString()
        {
            return string.Format("Part Number: {0}\nPart Description: {1}\nQuantity: {2}\nPrice Per Item: {3}",
                PartNumber, PartDescription, Quantity, PricePerItem);
        }//end method ToString

        public decimal GetPaymentAmount()
        {
            return Quantity * PricePerItem;
        }

        public int Quantity
        {
            get
            {
                return quantity;
            }
            set
            {
                quantity = (value > 0) ? value : 0;
            }
        }//end property Quantity

        public decimal PricePerItem
        {
            get
            {
                return pricePerItem;
            }
            set
            {
                pricePerItem = (value > 0) ? value : 0;
            }
        }//end propoerty PricePerItem
    }//end class Invoice 
}
